package com.ruitu.health_1.mvp.model;

import com.ruitu.arad.base.BaseModel;
import com.ruitu.health_1.dao.http.APIRetrofit;
import com.ruitu.router_module.bean.BaseResult2;
import com.ruitu.router_module.bean.cart.Cart;
import com.ruitu.router_module.bean.order.ConfirmOrder;
import com.ruitu.router_module.bean.product.Sku;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.RequestBody;

public class ShoppingCartModel {
    public static class ShoppingCartM extends BaseModel {
        public Observable<BaseResult2<List<Cart>>> cartList(String memberId) {
            return APIRetrofit.getDefault().cartList(memberId)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2<List<Sku>>> getProductSku(String productId) {
            return APIRetrofit.getDefault().getProductSku(productId)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2> updateSku(RequestBody body){
            return APIRetrofit.getDefault().updateSku(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2> deleteCart(RequestBody body) {
            return APIRetrofit.getDefault().deleteCart(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2<ConfirmOrder>> settlement(RequestBody body) {
            return APIRetrofit.getDefault().settlement(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2> changeQuantity(RequestBody body) {
            return APIRetrofit.getDefault().changeQuantity(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }
    }
}
